package com.hardroid.workload.utils;

import java.util.ArrayList;

import com.hardroid.workload.ui.widget.ResultObsvItemView;
import com.hardroid.workload.workcalc.ObsvResultItem;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class ResultObsvAdapter extends BaseAdapter {

	public ArrayList<ObsvResultItem> lResult;
	public Context context;
	
	public ResultObsvAdapter(Context context, ArrayList<ObsvResultItem> lResult) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.lResult = lResult;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lResult.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return lResult.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView ==null){
			convertView = new ResultObsvItemView(context ,(ObsvResultItem)getItem(position), position);
		}else{
			((ResultObsvItemView)convertView).setResult((ObsvResultItem)getItem(position), position);
		}
		return convertView;
	}

}
